package com.xiaoyg.lock;

public class TestVisibility {
    private static boolean flag = true;
    public static void main(String[] args) throws InterruptedException {

        new Thread(()->{
            while(flag){

            }
        }).start();

        Thread.sleep(2000);

        new Thread(()->{
            flag = false;
            System.out.printf("线程修改了变量的值为false");
        }).start();
    }

}
